import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param pHead1 ListNode类 
     * @param pHead2 ListNode类 
     * @return ListNode类
     */
    public ListNode Merge (ListNode pHead1, ListNode pHead2) {
        ListNode dummary=new ListNode(-1);
        ListNode last=dummary;
        ListNode cur1=pHead1;
        ListNode cur2=pHead2;

        while(cur1!=null&&cur2!=null){
            if(cur1.val>cur2.val){
                last.next=cur2;
                last=cur2;
                cur2=cur2.next;
            }else{
                last.next=cur1;
                last=cur1;
                cur1=cur1.next;
            }
        }
        if(cur1!=null){
            last.next=cur1;
        }else{
            last.next=cur2;
        }
        return dummary.next;
    }
}